home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / admin / linuxcon.000 / linuxcon / linuxconf-1.6 / userconf / passwd_valid.c < prev    next >
C/C++ Source or Header  |  1996-03-01  |  2KB  |  61 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include "../misc/misc.h"
  5. #include "../dialog/dialog.h"
  6. #include "internal.h"
  7. #include "userconf.h"
  8. #include "../paths.h"
  9. #include "userconf.m"
  10.  
  11. extern USERCONF_HELP_FILE help_password;
  12.  
  13. static const char PASSWD[] = "passwd";
  14. static const char MINLEN[] = "minlen";
  15. static const char MINNONALPHA[] = "minnonalpha";
  16.  
  17. static int passwd_valid_getval(const char *key, int defval)
  18. {
  19.     const char *pt = linuxconf_getval(PASSWD,key);
  20.     if (pt != NULL) defval = atoi(pt);
  21.     return defval;
  22. }
  23.  
  24. PUBLIC void PASSWD_VALID::write()
  25. {
  26.     linuxconf_replace (PASSWD,MINLEN,minlen);
  27.     linuxconf_replace (PASSWD,MINNONALPHA,minnonalpha);
  28.     linuxconf_save();
  29. }
  30. PUBLIC PASSWD_VALID::PASSWD_VALID()
  31. {
  32.     minlen = passwd_valid_getval(MINLEN,6);
  33.     minnonalpha = passwd_valid_getval(MINNONALPHA,0);
  34. }
  35.  
  36. /*
  37.     Edit the password setting policies
  38. */
  39. PUBLIC void PASSWD_VALID::edit()
  40. {
  41.     if(perm_rootaccess(MSG_U(P_PASSPOLICIES
  42.         ,"set the password policies"))){
  43.         DIALOG dia;
  44.         dia.newf_num (MSG_U(F_MINLEN,"Minimum length"),minlen);
  45.         dia.newf_num (MSG_U(F_MINCHARS,"Minimum amount of non alpha char")
  46.             ,minnonalpha);
  47.         if (dia.edit (
  48.             MSG_U(T_PASSPOLICIES,"Password setting polycies")
  49.             ,MSG_U(I_PASSPOLICIES
  50.              ,"You must enter here the validation rules\n"
  51.               "for password. Once setup, a user (or you) won't\n"
  52.               "be able to change a password to one that does\n"
  53.               "fullfill this requirements\n")
  54.             ,help_password.getpath()
  55.             ,0)==MENU_ACCEPT){
  56.             write();
  57.         }
  58.     }            
  59. }
  60.  
  61.